import { login, register } from '../../api/User'

const User = {
  actions: {
    login ({ commit }, userInfo) {
      return new Promise((resolve, reject) => {
        login(userInfo.username, userInfo.password).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    register ({ commit }, userInfo) {
      return new Promise((resolve, reject) => {
        register(userInfo.username, userInfo.password).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
export default User
